package com.zfb.videoscript.service

import android.accessibilityservice.AccessibilityService
import android.view.accessibility.AccessibilityEvent
import com.zfb.videoscript.core.ScriptEngine

class ScriptAccessibilityService : AccessibilityService() {
    
    companion object {
        private var instance: ScriptAccessibilityService? = null
        private var scriptEngine: ScriptEngine? = null
        
        fun getInstance(): ScriptAccessibilityService? = instance
        
        fun getScriptEngine(): ScriptEngine? = scriptEngine
    }
    
    override fun onServiceConnected() {
        super.onServiceConnected()
        instance = this
        scriptEngine = ScriptEngine(this)
    }
    
    override fun onAccessibilityEvent(event: AccessibilityEvent?) {
        // 不需要处理事件
    }
    
    override fun onInterrupt() {
        scriptEngine?.stop()
    }
    
    override fun onDestroy() {
        super.onDestroy()
        scriptEngine?.stop()
        instance = null
        scriptEngine = null
    }
} 